package com.example.book.service;



import com.example.book.mapper.UserMapper;
import com.example.book.model.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserService {
    @Autowired
    private UserMapper userMapper;

    /**
     * 校验用户名和密码是否正确
     * @param name 用户名
     * @param password 密码
     * @return true: 密码正确   false: 密码错误
     */
    public Boolean checkPassword(String name, String password) {
        //根据用户名查询用户信息
        //校验密码是否正确
        UserInfo userInfo = userMapper.queryUserInfoByName(name);
        if (userInfo==null || userInfo.getId()<=0){
            return false;
        }
        return password.equals(userInfo.getPassword());
    }
}
